package com.demo.controller;

import com.demo.dto.LoginVerify;
import com.iohao.game.action.skeleton.annotation.ActionController;
import com.iohao.game.action.skeleton.annotation.ActionMethod;
import com.iohao.game.action.skeleton.core.exception.MsgException;

@ActionController(1)
public class DemoAction {
    /**
     * 示例 here 方法
     *
     * @param helloReq helloReq
     * @return HelloReq
     */
    @ActionMethod(0)
    public LoginVerify here(LoginVerify helloReq) {
        System.out.println("收到消息");
        helloReq.setName(helloReq.getJwt() + ", I'm here ");
        return helloReq;
    }

    /**
     * 示例 异常机制演示
     *
     * @param helloReq helloReq
     * @return HelloReq
     * @throws MsgException e
     */
    @ActionMethod(1)
    public LoginVerify jackson(LoginVerify helloReq) throws MsgException {
        String jacksonName = "jackson";
        if (!jacksonName.equals(helloReq.getName())) {
            throw new MsgException(100, "异常机制测试，name 必需是 jackson !");
        }
        helloReq.setName(helloReq.getName() + ", hello, jackson !");
        return helloReq;
    }
}